package com.yswy.backstage.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yswy.backstage.service.SoftnessService;
import com.yswy.backstage.service.WhitelistAppUserService;
import com.yswy.domain.entity.Softness;
import com.yswy.domain.entity.WhitelistAppUser;
import com.yswy.domain.vo.dto.BaseFilter;
import com.yswy.domain.vo.gld.addOrUpate.SoftnessAddOrUpdate;
import com.yswy.domain.vo.gld.addOrUpate.WhitelistAppUserAddOrUpdate;
import com.yswy.domain.vo.gld.addOrUpate.base.BaseReqVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;


@RestController
@RequestMapping("/whitelistAppUser")
@Api(tags = "白名单用户")
public class WhitelistAppUserController {
    @Autowired
    private WhitelistAppUserService whitelistAppUserService;



    @PostMapping("/listWhitelistAppUser")
    @ApiOperation(value = "白名单列表")
    public Page<WhitelistAppUser> listWhitelistAppUser(@RequestBody  BaseFilter req, HttpServletRequest request) {
        return whitelistAppUserService.listWhitelistAppUser(req);
    }

    @GetMapping("/AllWhitelistAppUser")
    @ApiOperation(value = "白名单列表")
    public List<WhitelistAppUser> AllWhitelistAppUser() {
        return whitelistAppUserService.AllWhitelistAppUser();
    }

    @PostMapping("/addOrUpadteWhitelistAppUser")
    @ApiOperation(value = "添加修改白名单")
    public void addOrUpadteWhitelistAppUser(@RequestBody @Validated(BaseReqVO.CREATE.class) WhitelistAppUserAddOrUpdate req, HttpServletRequest request) {
        whitelistAppUserService.addOrUpadteWhitelistAppUser(req);
    }


    @GetMapping("/delWhitelistAppUser")
    @ApiOperation(value = "删除白名单")
    public void delWhitelistAppUser(@RequestParam(value = "whitelistAppUserId") Long whitelistAppUserId, HttpServletRequest request) {
        whitelistAppUserService.delWhitelistAppUser(whitelistAppUserId);
    }
    @GetMapping("/updarteVipAppUserVip")
    @ApiOperation(value = "设置白名单用户为vip")
    public void updarteVipAppUserVip(@RequestParam(value = "whitelistAppUserId") Long whitelistAppUserId,
                                     @RequestParam(value = "projectId") Long projectId,
                                     HttpServletRequest request) {
        whitelistAppUserService.updarteVipAppUserVip(whitelistAppUserId , projectId);
    }
    @GetMapping("/delAppUser")
    @ApiOperation(value = "清除白名单用户数据")
    public void delAppUser(@RequestParam(value = "whitelistAppUserId") Long whitelistAppUserId,
                            @RequestParam(value = "projectId") Long projectId,
                            HttpServletRequest request) {
        whitelistAppUserService.delAppUser(whitelistAppUserId , projectId);
    }

}
